﻿<UserControl x:Class="ModernAudioTagger.Pages.Rename"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:content="clr-namespace:ModernAudioTagger.Content"
             xmlns:view="clr-namespace:ModernAudioTagger.View"
             xmlns:provider="clr-namespace:ModernAudioTagger.Provider"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.DataContext>
        <Binding Source="{x:Static provider:ViewModelLocator.Instance}" Path="RenameVM" />
    </UserControl.DataContext>

    <UserControl.Resources>
        <Storyboard x:Key="stb_error">
            <ObjectAnimationUsingKeyFrames 
                Storyboard.TargetName="canvas_alert"
                Storyboard.TargetProperty="Visibility"                
                >
                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{x:Static Visibility.Hidden}"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <DockPanel>
        <Grid DockPanel.Dock="Bottom">

            <!-- content root for additional spacing -->
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <DockPanel>
                    
                    <Grid DockPanel.Dock="Top" Margin="{StaticResource DefaultMargin}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel Orientation="Horizontal" >
                            <mui:ModernButton ToolTip="Change working folder" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource openFolderPathData}" Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.OpenFolderDialogCommand}"  />
                            <mui:ModernButton ToolTip="Refresh folder content" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource refreshPathData}" Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.RefreshFilelistCommand}" Margin="{StaticResource DefaultLeftMargin}"  />
                            <!--<mui:ModernButton ToolTip="Sync path with tag section" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource arrowLeftRightPathData}" Command="{Binding SyncronizePathCommand}" Margin="{StaticResource DefaultLeftMargin}"  />-->
                            <Line Y1="0" Y2="24" Stroke="{DynamicResource SeparatorBackground}" Margin="{StaticResource LineMenuSeparator}"></Line>
                            <mui:ModernButton ToolTip="Rename target" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource pencilPathData}" Command="{Binding RenameObjectCommand}" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right">
                            <mui:ModernButton 
                            ToolTip="Help online"
                            Command="{x:Static view:ViewCommands.OpenUrl}" 
                            CommandParameter="{StaticResource doc_rename}"
                            EllipseDiameter="24" IconWidth="16" IconHeight="16"                           
                            HorizontalAlignment="Right"
                            Margin="{StaticResource DefaultRightMargin}"
                            IconData="{StaticResource helpPathData}"
                            />
                        </StackPanel>
                    </Grid>
                    
                    <content:ContentRename />
                </DockPanel>

                <!-- optional header -->
                <!--<Grid Margin="{StaticResource HeaderMargin}" HorizontalAlignment="Right" VerticalAlignment="Top">
                <Rectangle />
                <TextBlock Text="header" />
            </Grid>-->


                <!-- optional status -->
                <Grid Grid.Row="1" Margin="{StaticResource StatusMargin}" >
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="{StaticResource DefaultLeftMargin}" Text="{Binding Status}" />
                        <Canvas x:Name="canvas_alert" Margin="{StaticResource DefaultLeftMargin}" Width="20" Height="20" VerticalAlignment="Bottom" Visibility="Hidden">
                            <Path Fill="#FF000000" Stretch="Uniform" Width="16" Height="16" Data="{StaticResource alertPathData}" />
                        </Canvas>
                    </StackPanel>
                </Grid>
            </Grid>
        </Grid>
    </DockPanel>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="OnRenameErrorEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=RenameVM}">
            <ei:ControlStoryboardAction Storyboard="{StaticResource stb_error}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <!--<i:Interaction.Triggers>
        <i:EventTrigger EventName="OnTagErrorEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=TrackTagVM}">
            <ei:ChangePropertyAction TargetName="canvas_alert" PropertyName="Visibility" Value="Visible" />
        </i:EventTrigger>
    </i:Interaction.Triggers>-->

</UserControl>
